import 'package:flutter/material.dart';

enum Direction {
  vertical,
  horizontal
}

class CustomIconButton extends StatelessWidget {

  final Widget icon;
  final Widget child;
  final double? spacing;
  final VoidCallback? onTap;
  final Axis direction;
  final double? width;
  final double? height;
  final EdgeInsetsGeometry? margin;
  final EdgeInsetsGeometry? padding;

  const CustomIconButton({Key? key, required this.icon, required this.child, this.onTap, this.spacing = 0, this.direction = Axis.vertical, this.width, this.height, this.margin, this.padding}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        color: Colors.transparent,
        width: width,
        height: height,
        margin: margin,
        padding: padding,
        alignment: Alignment.center,
        child: Flex(
          direction: direction,
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          children: [
            icon,
            SizedBox(height: spacing, width: spacing),
            child
          ]
        )
      )
    );
  }
}